import ParentHook from '../Hook.js';
class Hook extends ParentHook {
	constructor(...args) {
		super(...args);
		this.stack = 'vue';
	}
	hookInitParam(area, { valueName, eventName }, param) {
		const { values, initialValues } = area.nameManger;
		const { onEvent, name, ...other } = param;
		const customEvent = other[eventName];
		// 原values中的数据为staticValues提供，优先级相对较低
		if (name in initialValues) values[name] = initialValues[name];
		// 对属性值绑定观察器，当数据变化时，更新渲染
		other[valueName] = { $proxy: values, field: name };
		// 这里不能定义为异步函数
		other[eventName] = e => {
			const value = area.exec(onEvent, [e], e);
			values[name] = value;
			area.exec(customEvent, [value]);
		};
		other.name = name;
		return other;
	}
}
export default Hook;